﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ST.Buz.Base.Entity;
using ST.Buz.Base.Enums;

namespace ST.Buz.Base.Mapping
{
	public partial class Map_Sys_UserAddress : IEntityTypeConfiguration<Sys_UserAddress>
	{
		public void Config(EntityTypeBuilder<Sys_UserAddress> builder)
		{
			builder.HasIndex(e => e.UserID)
				.HasName("IX_Sys_UserAddress")
				.IsClustered(false);

			builder.Property(e => e.UserID)
				.HasColumnType("char(32)");

			builder.Property(e => e.AddDate)
				.HasDefaultValueSql("(getdate())")
				.ValueGeneratedNever();

			builder.Property(e => e.LastModifyDate)
				.HasDefaultValueSql("(getdate())")
				.ValueGeneratedNever();

			builder.Property(e => e.Type)
				.HasDefaultValueSql("((" + (int)AddressType.通用 + "))")
				.ValueGeneratedNever();

			builder.Property(e => e.ZipCode)
				.IsUnicode(false);

			builder.Property(e => e.Mobile)
				.IsUnicode(false);

			//builder.Property(e => e.Telephone)
			//	.IsUnicode(false);

			builder.Property(e => e.Sort)
				.HasDefaultValueSql("((0))")
				.ValueGeneratedNever();
		}
	}
}
